/*******************************************************************
 * Copyright (C) yel_hb-USTC, 2012                                
 *                                                                  
 * FILE NAME             :  kahansum.h                                 
 * PRINCIPAL AUTHOR      :  yel_hb                               
 * MODULE NAME           :  KAHANSUM                             
 * LANGUAGE              :  C++                                      
 * TARGET ENVIRONMENT    :  windows                                   
 * DATE OF FIRST RELEASE :  2012/12/14                              
 * DESCRIPTION           :  Kahan Summation class definition, to use  
 *							the add method to eliminate precision 
 *							error caused by round off.
 ******************************************************************/

/*
 * Revision log:
 *
 * Created by yel_hb,2012/12/14
 * Modified by yel_hb,2012/12/18
 *
 */

#ifndef KAHANSUM_H     
#define KAHANSUM_H    1

class KahanSum
{
public:
	KahanSum ();
	void	reset ();
	void	add ( double value );
	double	get_sum ();
	~KahanSum ();
private:
	double sum;
	double c;
	double y;
	double t;
};

#endif